<?php
session_start();
if(!isset($_SESSION['username'])){
	header("location:../index.php");
}
?>

<link href="../css/table.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function load()
{
window.print(this);
}
</script>
<?php
include "../inc/db.php";
$kota = $_GET['kota'];
if($_GET['set'] == "reportall"){
	if($_POST['kota']=="All"){
		$result = mysql_query("select * from tb_site where kota like '%%' group by kota asc;");
	}else{
		$result = mysql_query("select * from tb_site where kota like '%$_POST[kota]%' group by kota asc;");
	}
}elseif($_GET['set'] == "reportex"){
$sql="SELECT DATE_ADD(now(),INTERVAL (select * from tb_expired) DAY), now();";
$hasil=mysql_query($sql);
$kolom=mysql_fetch_array($hasil);
echo $kota;
$sql="select * from tb_site where kota like '%$_POST[kota]%' and tgl_habis_kontrak between '$kolom[1]' and '$kolom[0]' group by kota asc;";

$result = mysql_query($sql);
}
?>
<body align="center" onLoad="load()">
<h2 align="center">SITE REPORT</h2>
<?php
if(mysql_num_rows($result) >= 1){
?>
<table width="518" class="bordered" align="center">
  <tr>
    <td width="60">Nama Site </td>
    <td width="100">Tanggal Kontrak</td>
    <td width="100">Tanggal Habis Kontrak</td>
    <td width="64">Lokasi Site</td>
    <td width="52">Kota</td>
    <td width="89">Keterangan 1</td>
    <td width="73">Ketrangan 2</td>
  </tr>
  <?php
  while($kolom=mysql_fetch_array($result)){
  ?>
  <tr>
    <td><?php echo $kolom[1]; ?></td>
    <td><?php echo $kolom[2]; ?></td>
    <td><?php echo $kolom[3]; ?></td>
    <td><?php echo $kolom[4]; ?></td>
    <td><?php echo $kolom[5]; ?></td>
    <td><?php echo $kolom[6]; ?></td>
    <td><?php echo $kolom[7]; ?></td>
  </tr>
  <?php
  }
  ?>
</table>
<?php
}else{
?>
<h2 align="center">Data Tidak Ditemukan</h2>
<?php
}
?>
</body>
